#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
    pid_t id = fork();
    if (id < 0)
    {
        perror("fork");
    }
    else if (id == 0)
    {
        printf("I am child process: %d\n", getpid());
        sleep(5);
        exit(0);
    }
    else{
        int status = 0;
        pid_t rid = waitpid(id, &status, 0);
        if (rid > 0)
            printf("exit_code: %d, exit_signal: %d\n", (status >> 8)&0xFF, status&0x7F);
    }

    return 0;
}
